package net.chathu.airgw.packets.chat 
{
	import net.chathu.airgw.Config;
	import net.chathu.airgw.Debug;
	import net.chathu.airgw.packets.gw.serverpackets.EchoPacket;
	import net.chathu.airgw.util.StringUtil;

	/**
	 * ...
	 * @author ze
	 */
	public class AuthOk extends ChatPacket 
	{
		
		public function AuthOk() 
		{
			
		}
		
		override public function execute():void
		{
			var userData:Array = String(data[2]).split("\u9999");
			trace("PARAMS LEN: " + userData.length);
			sessionData.chatData.username = StringUtil.convertFromISO88591(userData[0]);
			sessionData.chatData.isModerator = (userData[1] == "1");
			//userData[2] == ?
			sessionData.chatData.isRegistered = (userData[3]=="1");
			sessionData.chatData.isLimited = (userData[4] == "1");
			
			sendParamsToChat(["sub", "userinfo"]);
			sendParamsToChat(["sub","confrooms"]);
			sendParamsToChat(["sub","rooms"]);
			sendParamsToChat(["gettreestate"]);
			sendParamsToChat(["roomrights", "rooms"]);
			sendParamsToChat(["sub", "users"]);
			sendParamsToChat(["sub", "private"]);
			sendParamsToChat(["autosubrooms"]);
			sendParamsToChat(["sub","messages"]);
			sendParamsToChat(["gettime"]);
			sendParamsToChat(["initend"]);
			Debug.echo("Logged in with user: " + sessionData.chatData.username);
			sendToClient(new EchoPacket(Config.GW_ECHO_NICK, "Logged in with user: '" + sessionData.chatData.username + "'"));

			
		}
		
	}

}